package com.spzx.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.spzx.user.domain.Region;
import com.spzx.user.mapper.RegionMapper;
import com.spzx.user.service.IRegionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 * 地区信息表 服务实现类
 * </p>
 *
 * @author xiongkunYang
 * @since 2025/06/05 09:08
 */
@Service
public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> implements IRegionService {


    @Override
    public String getNameByCode(String code) {
        if (!StringUtils.hasText(code)) {
            return "";
        }
        Region region = this.baseMapper.selectOne(new LambdaQueryWrapper<Region>().eq(Region::getCode, code).select(Region::getName));
        if (null != region) {
            return region.getName();
        }
        return "";
    }
}
